package ManagerSystem;

import java.util.Scanner;

import tjut.db.DBDriverFactory;

/**
 * 添加好友
 * @author ChrisL
 *
 */
public class AddFriend {

	public void NewFriend(String UserStu){
		Scanner input=new Scanner(System.in);
		SearchInfo si=new SearchInfo();
		si.SearchStu();
		System.out.println("请选择你想添加的好友ID：");
		String Frdid=input.next();
		System.out.println("请输入该好友的备注");
		String Frdremark=input.next();
		String strSQL3 = "INSERT INTO FRIEND(STU_ID,FRD_ID,REMARK) VALUES(?,?,?) ";
		int i3 =  DBDriverFactory.getDBDriverInstance().update(strSQL3,new Object[] {UserStu,Frdid,Frdremark});
		String strSQL4 = "UPDATE FRIEND SET FRD_NAME=(SELECT STU_NAME FROM MANAGERSYS WHERE STU_ID=?)";
		int i4 =  DBDriverFactory.getDBDriverInstance().update(strSQL4,new Object[] {Frdid});
		System.out.println(i3>0?"添加好友成功":"添加好友失败");
	}
}
